<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTikuOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tiku_order', function (Blueprint $table) {
            $table->id();
            $table->integer('userId', false, true)->comment('用户ID');
            $table->integer('courseId', false, true)->nullable()->comment('学科ID');
            $table->integer('relationId', false, true)->nullable()->comment('关联ID，必知必学：激活码，启航：激活码|题库');
            $table->string('tradeNo')->unique()->comment('订单号');
            $table->string('wxTradeNo')->nullable()->comment('微信单号');
            $table->string('wxSign')->nullable()->comment('微信');
            $table->string('wxPrepayId')->nullable()->comment('微信预支付交易会话标识，2小时有效期');
            $table->string('wxNonceStr')->nullable()->comment('微信');
            $table->string('refundTradeNo')->nullable()->comment('退款单号');
            $table->decimal('price')->comment('金额');
            $table->tinyInteger('status')->default(1)->comment('状态，1：未支付，2：已支付，3：手动支付，4：已完成，5: 已取消，8：已支付但商品发放失败，9：已退款');
            $table->tinyInteger('type')->comment('类型，1：直接购买，2：购买激活码，3:购买视频课程，4:购买专栏');
            $table->dateTime('buyAt')->comment('下单时间');
            $table->dateTime('payAt')->nullable()->comment('支付时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tiku_order');
    }
}
